<?php
namespace app\index\controller;

use app\common\controller\Home;
use app\common\model\IndustryExhibition;
use app\common\model\Industry as Industrys;
use app\common\model\Ip;
use PHPExcel_IOFactory;
use PHPExcel;
use think\Db;
class Industry extends Home
{
    public function initialize()
    {
        parent::initialize();
    }
    

    public function index()
    {
         return $this->fetch();
    }

    public function show($id)
    {
        $exhi_mod = new IndustryExhibition();
        $industry_mod = new Industrys();
        $detail = $industry_mod->detail($id);
        if (!$detail) {
             $this->redirect('/404');
        }
        $sonlist = $industry_mod->sonlist($id);
        // dump($detail);
        // dump($sonlist);
        foreach ($sonlist as $key => &$value) {
            $res = Industrys::get($value['id']);
            // dump($res->exhibitions);
            $order = 'sorts desc,id desc';
            $exhibitions = $res->exhibitions()->order($order)->limit(8)->select();
            $value['exhibition'] = $exhibitions;
        }
       
        // dump($sonlist);
        // $test = 'xxx';
 
        $this->assign(compact('detail','sonlist'));
        return $this->fetch();
    }

    public function error()
    {
        return $this->fetch();
    }

}